package nz.wgtn.davidxwang.degreeauditor.logic;

import java.util.ArrayList;

/**
 * Represents a single course.
 * 
 * @author David X Wang [300164091]
 *
 */
public class Course implements Comparable<Course>{
	//basic information
	private String title;
	private String discipline;
	private String courseCode;
	private int number;
	
	//requisites
	
	//restrictions and cotaught
	private ArrayList<Course> restrictions;
	private ArrayList<Course> cotaught;
	private ArrayList<Course> alsoOfferedAs;
	
	/**
	 * Creates a new course object with very basic information.
	 * @param title the full title of the course
	 * @param disc the discipline which this course belongs to
	 * @param num the course number
	 */
	public Course(String title, String disc, int num){
		this.title = title;
		discipline = disc;
		number = num;
		courseCode = disc + num;
	}
	
	public String getTitle(){
		return title;
	}
	
	public String getDiscipline(){
		return discipline;
	}
	
	public String getCourseCode(){
		return courseCode;
	}
	
	public int getNumber(){
		return number;
	}
	
	@Override
	public int hashCode() {
		return (courseCode == null)? 0 : courseCode.hashCode();
	}
	
	@Override
	public String toString(){
		return courseCode;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Course other = (Course) obj;
		return courseCode.equals(other.courseCode);
	}

	@Override
	public int compareTo(Course o) {
		return courseCode.compareTo(o.courseCode);
	}
}
